﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MatchmakingPartner.cs" company="DissingNelleman">
//   
// All rights reserved. </copyright>
// <summary>
//   The matchmaking partner.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace ServiceLibrary.Services.Dto
{
    using System;
    using System.Runtime.Serialization;

    /// <summary>
    /// The matchmaking partner.
    /// </summary>
    [DataContract]
    public class MatchmakingPartner
    {
        #region Public Properties

        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        [DataMember]
        public Guid ID { get; set; }

        /// <summary>
        /// Gets or sets the other text.
        /// </summary>
        [DataMember]
        public string OtherText { get; set; }

        /// <summary>
        /// Gets or sets the product development text.
        /// </summary>
        [DataMember]
        public string ProductDevelopmentText { get; set; }

        /// <summary>
        /// Gets or sets the sales text.
        /// </summary>
        [DataMember]
        public string SalesText { get; set; }

        /// <summary>
        /// Gets or sets the test text.
        /// </summary>
        [DataMember]
        public string TestText { get; set; }

        /// <summary>
        /// Gets or sets the type.
        /// </summary>
        [DataMember]
        public Guid Type { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The convert.
        /// </summary>
        /// <param name="matchmakingPartner">
        /// The matchmaking partner.
        /// </param>
        /// <returns>
        /// The <see cref="MatchmakingPartner"/>.
        /// </returns>
        public static MatchmakingPartner Convert(Models.Domain.MatchmakingPartner matchmakingPartner)
        {
            if (matchmakingPartner != null)
            {
                var dto = new MatchmakingPartner
                              {
                                  ID = matchmakingPartner.ID, 
                                  Type = matchmakingPartner.Type.ID, 
                                  OtherText = matchmakingPartner.OtherText, 
                                  ProductDevelopmentText = matchmakingPartner.ProductDevelopmentText, 
                                  SalesText = matchmakingPartner.SalesText, 
                                  TestText = matchmakingPartner.TestText
                              };
                return dto;
            }
            
            return null;
        }

        #endregion
    }
}

namespace ServiceLibrary.Services.Queries
{
    using System.Runtime.Serialization;

    using NHibernate;

    using ServiceLibrary.Actioners.Activities;
    using ServiceLibrary.Services.Results;

    /// <summary>
    /// The matchmaking partner query.
    /// </summary>
    [DataContract]
    public class MatchmakingPartnerQuery : IQuery
    {
        #region Public Methods and Operators

        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="hsession">
        /// The hsession.
        /// </param>
        /// <returns>
        /// The <see cref="IResult"/>.
        /// </returns>
        public override IResult Execute(ISession hsession)
        {
            var actioner = new MatchmakingPartnerActioner(hsession, null);

            return actioner.ExecuteSearchQuery(this);
        }

        #endregion
    }
}

namespace ServiceLibrary.Services.Results
{
    using System.Collections.Generic;
    using System.Runtime.Serialization;

    using ServiceLibrary.Services.Dto;

    /// <summary>
    /// The matchmaking partner result.
    /// </summary>
    [DataContract]
    public class MatchmakingPartnerResult : IResult
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="MatchmakingPartnerResult"/> class.
        /// </summary>
        public MatchmakingPartnerResult()
        {
            this.List = new List<MatchmakingPartner>();
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the list.
        /// </summary>
        [DataMember]
        public List<MatchmakingPartner> List { get; set; }

        /// <summary>
        /// Gets or sets the total row count.
        /// </summary>
        [DataMember]
        public int TotalRowCount { get; set; }

        #endregion
    }
}

namespace ServiceLibrary.Services.Commands
{
    using System;
    using System.Runtime.Serialization;

    using NHibernate;

    using ServiceLibrary.Actioners.Activities;
    using ServiceLibrary.Services.Dto;

    using User = ServiceLibrary.Models.Domain.User;

    /// <summary>
    /// The create matchmaking partner command.
    /// </summary>
    [DataContract]
    public class CreateMatchmakingPartnerCommand : ICommand
    {
        #region Public Properties

        /// <summary>
        /// Gets or sets the new matchmaking partner.
        /// </summary>
        [DataMember]
        public MatchmakingPartner NewMatchmakingPartner { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="hsession">
        /// The hsession.
        /// </param>
        /// <param name="activeUser">
        /// The active user.
        /// </param>
        public override void Execute(ISession hsession, User activeUser)
        {
            var actioner = new MatchmakingPartnerActioner(hsession, activeUser);
            actioner.CreateMatchmakingPartner(this);
        }

        #endregion
    }

    /// <summary>
    /// The update matchmaking partner command.
    /// </summary>
    [DataContract]
    public class UpdateMatchmakingPartnerCommand : ICommand
    {
        #region Public Properties

        /// <summary>
        /// Gets or sets the dto.
        /// </summary>
        [DataMember]
        public MatchmakingPartner Dto { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="hsession">
        /// The hsession.
        /// </param>
        /// <param name="activeUser">
        /// The active user.
        /// </param>
        public override void Execute(ISession hsession, User activeUser)
        {
            var actioner = new MatchmakingPartnerActioner(hsession, activeUser);
            actioner.UpdateMatchmakingPartner(this);
        }

        #endregion
    }

    /// <summary>
    /// The delete matchmaking partner command.
    /// </summary>
    [DataContract]
    public class DeleteMatchmakingPartnerCommand : ICommand
    {
        #region Public Properties

        /// <summary>
        /// Gets or sets the dto.
        /// </summary>
        [DataMember]
        public Guid? Dto { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="hsession">
        /// The hsession.
        /// </param>
        /// <param name="activeUser">
        /// The active user.
        /// </param>
        public override void Execute(ISession hsession, User activeUser)
        {
            var actioner = new MatchmakingPartnerActioner(hsession, activeUser);
            actioner.DeleteMatchmakingPartner(this);
        }

        #endregion
    }
}